precision mediump float;

uniform vec4 ambientColor;
uniform vec4 diffuseColor;
uniform vec4 specularColor;

varying vec3 vVaryingLightDir;
varying vec3 vVaryingNormal;

void main(){
	vec4 vFragColor = ambientColor;
	float diff = max(0.0 , dot(vVaryingNormal,vVaryingLightDir));
	vFragColor += diff*diffuseColor;
	vec3 vReflect = normalize( reflect( normalize(-vVaryingLightDir) , normalize(vVaryingNormal) ));
	float spec= max(0.0 , dot( vVaryingNormal, vReflect));
	if(diff != 0.0){
		float fSpec=pow(spec,128.0);
		vFragColor.rgb+= vec3(fSpec,fSpec,fSpec);
	}
	gl_FragColor=vFragColor;
}